<template>
  <div>
    <el-menu
      :default-active="activeMenu"
      class="el-menu-vertical-demo"
      background-color="#2c3e50"
      :collapse-transition="false"
      :unique-opened="true"
      :router="true"
      text-color="#fff"
      :collapse="isCollapse"
    >
      <el-menu-item index="/">
        <img :src="login" alt="" class="login mr">
        <span slot="title" class="l-title">站点导航</span>
      </el-menu-item>
      <submenuItem v-for="(item, index) in menut" :key="index" :item="item" />
    </el-menu>
  </div>
</template>

<script>
import db from '@/utils/localstorage'
import submenuItem from './submenuItem'
import login from '@/assets/logo.png'
export default {
  name: 'Submenu',
  components: { submenuItem },
  props: {
    isCollapse: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      login,
      menut: db.get('USER_ROUTER')
    }
  },
  computed: {
    activeMenu() {
      const route = this.$route
      const { path } = route
      return path
    }
  }
}
</script>

<style scoped>
.el-menu-vertical-demo {
    border: none;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
    min-height: 400px;
}
    .login {
        width: 30px;
        height: 30px;
    }
    .mr {
        margin-right: 10px;
    }
    .l-title {
        font-size: 18px;
    }
</style>
